package com.grp6.game.ui.platform.swing;

import java.awt.GridBagLayout;

import javax.swing.JFrame;

import com.grp6.game.ui.platform.IAbstractUIPlatformFactory;
import com.grp6.game.ui.platform.ICell;
import com.grp6.game.ui.platform.IDialog;



public class SwingUIFactory implements IAbstractUIPlatformFactory{

	public static class BaseFrame extends JFrame{
		private static final long serialVersionUID = 1L;
		
		public BaseFrame(){
			//this.setResizable(false);
			this.setLayout(new GridBagLayout());
			this.setVisible(true);
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		}
	}
	private BaseFrame frame;
	
	private BaseFrame getBaseFrame(){
		if (frame==null)
			frame = new BaseFrame();
		return frame;
	}
	
	
	@Override
	public ICell createICell(int x, int y) {
		return new SwingCell(getBaseFrame(),x,y);
	}

	@Override
	public IDialog createIDialog() {
		return new SwingDialog(getBaseFrame());
	}

	@Override
	public void cleanUp() {
		frame.dispose();
	}
}
